﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.SessionState;

namespace PaymentHelper.Core.CommonUtils
{
    public class SessionStorage:ITemporaryStorage
    {
        private string _keyName;

        public SessionStorage()
        {         
        }

        public SessionStorage(string keyName)
        {
            _keyName = keyName;
        }

        public void SaveObject(object obj)
        {
            HttpContext.Current.Session[_keyName] = obj;
        }

        public void SaveObject(string name, object obj)
        {
            HttpContext.Current.Session[name] = obj;
        }

        public object GetObject()
        {
            return HttpContext.Current.Session[_keyName];
        }

        public object GetObject(string name)
        {
            return HttpContext.Current.Session[name];
        }

        public bool CheckExist()
        {
            return HttpContext.Current.Session[_keyName] != null;
        }

        public bool CheckExist(string name)
        {
            return HttpContext.Current.Session[name] != null;
        }
    }
}
